<section class="invoice">
    <!-- title row -->
    <div class="row">
        <div class="col-xs-12">
            <h2 class="page-header">
                <i class="fa fa-globe"></i>课程详情
            </h2>
        </div>
    </div>
    <!-- info row -->
    <div class="row invoice-info">
        <div class="col-sm-4 invoice-col">
            <b>周数：</b>  {{ $course->week }} <br>
            <b>时间：</b>  {{ $class->class_time }} <br>
        </div>
        <div class="col-sm-4 invoice-col">
            <b>星期：</b>  <font id="weekday"></font> <br>
            <b>老师：</b>  {{ $class->teacher_name }}<br>
        </div>
        <div class="col-sm-4 invoice-col">
            <b>课程名称：</b> {{ $course->name }} <br>
            <b>课时：</b> {{ $course->class_hour }} </b>

            <br>
        </div>
    </div>
    <br />

    <div class="row">
        <div class="col-xs-12 table-responsive">
            <table class="table table-striped" id="childlist">
                <thead>
                <tr>
                    <th style="width:60px">学生</th>
                    <th width="60px">签到</th>
                    <th width="60px"></th>
                </tr>
                </thead>
                <tbody>
                @if($children != null)
                @foreach($children as $child)
                    <tr>
                        <td>{{ $child->name }}</td>
                        <td>
                            @if($child->created_time == null)
                                <button type="button" class="btn btn-primary btn-sm" style="margin-right: 5px;" data-url="{{ url('/admin/child/sign/'.$class->class_id.'/'.$child->id.'/'.$course->id) }}" data-type="POST" onclick="subAction(this)">签 到</button>
                            @else
                                {{ $child->created_time }}
                            @endif
                        </td>
                        <td>
                            <button type="button" class="btn btn-default btn-sm" style="margin-right: 5px;" data-content="{{ $class->class_id.'/'.$child->id.'/'.$course->age.'/'.$class->weekday }}" onclick="buqian(this)">补 签</button>
                        </td>
                    </tr>
                @endforeach
                @endif
                </tbody>
            </table>
        </div>
        <!-- /.col -->
    </div>
    <div class="row no-print">
        <div class="col-xs-12">
            <button type="button" class="btn btn-default" style="margin-right: 5px;" data-url="{{ url('/admin/classes') }}" onclick="jumpfun(this)">返 回</button>
        </div>
    </div>
</section>
<div class="modal modal-primary fade" id="modal-primary">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">补 签</h4>
            </div>
            <div class="modal-body">
                <input class="form-control" id="week" name="week" placeholder="补签的周数">
                <input type="hidden" id="url">
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-outline pull-right" data-dismiss="modal">Close</button>
                <button type="button" class="btn btn-outline pull-left" onclick="retroactive(this)">补 签</button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<script type="text/javascript">
    $(function(){
        switch ({!! $class->weekday !!}){
            case 1:
              x="一";
              break;
            case 2:
              x="二";
              break;
            case 3:
              x="三";
              break;
            case 4:
              x="四";
              break;
            case 5:
              x="五";
              break;
            case 6:
              x="六";
              break;
            case 7:
              x="日";
              break;
        }
        $("#weekday").html(x);
    })

    function buqian(obj) {
        var content = $(obj).attr("data-content");
        $("#url").val(content);
        $('#modal-primary').modal('show');
    }

    function retroactive(obj) {
        var cont = $("#url").val();
        var week = $("#week").val();
        var url = "admin/child/retroactive/" + cont + "/" + week;
        $.post(url,function (data) {
            var result = JSON.parse(data);
            if(result.code == 1){
                $('#modal-primary').modal('toggle');
                swal("操作成功!", result.msg, "success");
                getContent(result.url);
            }else {
                swal("操作失败!", result.msg, "error");
            }
        })
    }
</script>
